#pragma once 
#include<pthread.h>
#include<unistd.h>
#include"Protocol.hpp"
#include"tcpserver.hpp"
#include"Tack.hpp"
#include"Log.hpp"
#include"threadPool.hpp"
#define PORT 8081

class http_server{
  private:
    int port;
    bool flag;
  public:
    http_server(int _port=PORT):port(_port),flag(false)
    {}
    ~http_server(){}

    void Start()
    {
      while(!flag){
        struct sockaddr_in cpee;
        memset(&cpee,0,sizeof(cpee));
        socklen_t len=sizeof(cpee);
        int sock=accept(tcp_server::GetTcpObj(port)->lisent_sock,(struct sockaddr*)&cpee,&len);
        if(sock<0){
          continue;
        }
        LOG(INFO,"accept success");
        Tack tack(sock);
        ThreadPool::GetThread()->PushTack(tack);
      }
    }
};
